package a.b.c;

import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

import androidx.appcompat.app.AppCompatActivity;

import javax.inject.Inject;

/**
 * 代码参考 https://www.jianshu.com/p/626b2087e2b1
 * 另一篇：https://blog.csdn.net/u010257931/article/details/104790257/
 */
public class MainActivity extends AppCompatActivity implements ICommonView {

    private Button mBtnLogin;

    @Inject
    LoginPresenter presenter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        DaggerCommonComponent.
                builder().
                commonModule(new CommonModule(this)).
                build().
                inject(this);

        mBtnLogin = findViewById(R.id.btn_login);
        mBtnLogin.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                presenter.login(new User());
            }
        });
    }

    @Override
    public Context getContext() {
        return this;
    }
}
